<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>进度条</title>
    <style>
        #myProgress{
            width: 100%;
            background: #ddd;
        }
        #myBar{
            height: 30px;
            width: 1%;
            background: #4caf50;
        }
    </style>
</head>
<body>
<h1>JS进度条</h1>
<div id="myProgress">
    <div id="myBar"></div>
</div>
<br>
<button onclick="move()">点我</button>

<script>

    function move () {
      var elem = document.getElementById('myBar');
      var width = 1;
      var id = setInterval(frame,10);
      function frame () {
        if(width >= 100){
          clearInterval(id);
        }else{
          width++;
          elem.style.width = width + '%';;
        }
      }
    }

</script>

</body>
</html>